package com.day240701.controller;

import com.day240701.dao.BlogDao;
import com.day240701.entity.Blog;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;

@WebServlet(name = "UeditorServlet", value = "/ueditorServlet")
public class UeditorServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request,response);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String title = request.getParameter("title");
        String blogContent = request.getParameter("blogContent");

        BlogDao blogDao = new BlogDao();
        boolean flag = blogDao.addBlog(title, blogContent);
        if (flag) {
            System.out.println("添加博文成功");
        } else {
            System.out.println("添加博文失败");
        }

    }
}
